package com.wjc.business.controller.admin;




import com.wjc.business.BusinessApplication;
import com.wjc.server.dto.CommonDto;
import com.wjc.server.dto.CourseContentFileDto;
import com.wjc.server.service.CourseContentFileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;


@RestController
@RequestMapping("/admin/course-content-file")
public class CourseContentFileController {

    private static final Logger LOG= LoggerFactory.getLogger(BusinessApplication.class);
    public static final String BUSINESS_NAME = "课程内容文件";

    @Resource
    private CourseContentFileService courseContentFileService;

    //根据courseid查询
    @GetMapping("/list/{courseId}")
    public CommonDto list(@PathVariable Long courseId){
        List<CourseContentFileDto> list = courseContentFileService.list(courseId);
        CommonDto<List<CourseContentFileDto>> listCommonDto = new CommonDto<>();
        listCommonDto.setContent(list);
        return listCommonDto;
    }

    //保存
    @PostMapping("/save")
    public CommonDto list(@Valid @RequestBody CourseContentFileDto courseContentFileDto){
        CommonDto commonDto=new CommonDto<>();
        courseContentFileService.save(courseContentFileDto);
        return commonDto;

    }

    //删除
    @DeleteMapping("/delete/{id}")
    public CommonDto delete(@PathVariable Long id){
        CommonDto commonDto=new CommonDto<>();
        courseContentFileService.delete(id);
        return commonDto;
    }
}
